package com.qz.c2;

import com.qz.c2.stu;

import java.util.ArrayList;

public class students {
    public static void main(String[] args) {
        //将所有学生信息加入集合
        //创建了一个students集合，存储stu型数据
        ArrayList<stu> students = new ArrayList<stu>();
        students.add(new stu("单欣烁", 32,19,"女",1000.0));
        students.add(new stu("马璐瑶", 34,19,"女",1000.0));
        students.add(new stu("史佳健", 28,20,"女",900.0));
        students.add(new stu("史悦含", 30,19,"女",1500.0));
        students.add(new stu("袁思源", 24,20,"女",1600.0));
        students.add(new stu("王萌晓", 25,21,"女",2000.0));

        //打印所有学生信息
        System.out.println("***********402宿舍信息表*********");
        System.out.println("姓名    学号  年龄 性别  生活费");
        System.out.println("********************************");
        for (int i=0;i<students.size()-1;i++){
            stu s = students.get(i);
            System.out.println(s.name+"   "+s.id+"   "+s.age+"   "+s.gender+"   "+s.cost);
        }
        System.out.println("*********************************");
        //打印总年龄和总生活费
        double totalcost=0;
        int sumage=0;
        for (int i=0;i<students.size()-1;i++){
            stu s = students.get(i);
            totalcost+=s.cost;
            sumage+=s.age;
        }
        System.out.println("402宿舍月总生活费："+totalcost);
        System.out.println("402宿舍总年龄："+sumage);
        System.out.println("*********************************");
    }
}
